package com.book.controller;



import com.book.api.RankingApi;
import com.book.pojo.Score;
import com.book.result.Result;
import com.book.service.ScoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author cxy
 * @since 2023-10-13 10:29:15
 */
@RestController
@RequestMapping("/score")
public class ScoreController {

    @Autowired
    private ScoreService scoreService;
    @Autowired
    private RankingApi rankingApi;

    //读者对小说进行评分 不能重复对同一本书进行评分  1不能 2 能
    @PostMapping("insertScore")
    public Result insertScore(@RequestBody Score score){
        scoreService.insertScore(score);
        return Result.OK();
    }

    //读者对小说进行评分修改
    @PutMapping("updateScore")
    public Result updateScore(@RequestBody Score score){
        scoreService.updateScore(score);
        return Result.OK();
    }

    //评分榜表
    @GetMapping("ScoreRanking")
    public List<Score> ScoreRanking (){
        return scoreService.ScoreRanking();
    }

}
